# # 需求: 创建一个0-10的列表。
# # for循环实现
# list2 = []
# for i in range(11):
#     list2.append(i)
# # print(list2)
# # # 推导式实现
# # list3 = [r for r in range(11)]
# # print(list3)
# # # 需求: 创建一个0-10的偶数列表。
# # # for循环实现
# # list2 = []
# # for i in range(11):
# #     if i % 2 == 0:
# #         list2.append(i)
# # print(list2)
# # # # 推导式实现
# # list3 = [r for r in range(11) if r % 2 == 0]
# # print(list3)
#
# # # [(1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
# # # for循环构造
# # list1 = []
# # for a in range(1, 3):
# #     for b in range(3):
# #         list1.append((a, b))
# #
# # print(list1)
# # # 推导式实现
# # list2 = [(a, b) for a in range(1, 3) for b in range(3)]
# # print(list2)
#
# # ============================================================
# # 字典推导式
# # 创建一个字典:字典key是1-5数字, value是这个数字的2次方。
# dict1 = {}
# for i in range(1, 6):
#     dict1[i] = i ** 2
#
# print(dict1)
# # # 推导式实现
# # dict2 = {k: k ** 2 for k in range(1, 6)}
# # print(dict2)
# #
# list1 = ['name', 'age', 'gender']
# list2 = ['Tom', 20, 'man']
# #
# dict3 = {}
# for i in range(len(list1)):
#     dict3[list1[i]] = list2[i]
# print(dict3)
# #
# # dict4 = {list1[i]: list2[i] for i in range(len(list1))}
# # print(dict4)
# #
#
# grades = {'小明': 134, '大壮': 125, '二狗': 140, '柱子': 94, '王九哥': 88, "王七弟": 85}
#
# # 需求：提取上述成绩中大于等于100分的数据
# # for循环实现
# dict5 = {}
# for i in grades:
#     if grades[i] >= 100:
#         dict5[i] = grades[i]
#
# print(dict5)
# # 字典推导式实现
# dict6 = {i: grades[i] for i in grades if grades[i] >= 100}
# print(dict6)
#
# dict6 = {k: v for k, v in grades.items() if v >= 100}
# print(dict6)

# 需求:创建一个集合,数据为下方列表的2次方。
list1 = [1, 1, 2]
set1 = set()
for i in list1:
    set1.add(i ** 2)

print(set1)
set2 = {i ** 2 for i in list1}
print(set2)



# n = 6
# for i in range(2,n):
#     # 只要n被i整除了就证明n是合数,没有再除以下一个数了
# else:
#     # 如果循环没被break证明没被整除过,这个数就是质数了

str1 = "welocme to super&Test"
list1 = list(str1)
print(list1)
list1[0],list1[-1] = list1[-1],list1[0]
print(list1)

# a = 10
# b = 20
# a,b = b,a
# print(a)
# print(b)